package unitTest;

import java.rmi.RemoteException;
import java.util.ArrayList;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import vo.SelectLessonVO;
import SelectLessonBL.SelectLessonController;
import error.DoubleSelectException;
import error.QualificationException;
import error.TimeException;

public class SelectLessonTest extends TestCase
{

	private SelectLessonController slc;

	@Before
	public void setUp() throws Exception
	{
		slc = new SelectLessonController();
	}

	@After
	public void tearDown() throws Exception
	{
	}

	@Test
	public void testJoinLesson()
	{

		SelectLessonVO slv = new SelectLessonVO();
		slv.lesson = "1212001";
		slv.student = "121250080";
		slv.pass = false;

		try
		{
			slc.joinClass(slv);
		} catch (RemoteException | QualificationException | TimeException e1)
		{
			e1.printStackTrace();
		}

		try
		{
			slc.ManageSelectLesson("1212001");
		} catch (RemoteException | DoubleSelectException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TimeException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		SelectLessonVO aim = new SelectLessonVO();
		aim.lesson = "1212001";

		ArrayList<SelectLessonVO> list = new ArrayList<SelectLessonVO>();
		try
		{
			list = slc.getSelectLesson(aim);
		} catch (RemoteException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// Assert.assertEquals("121250080", list.get(0).student);
		Assert.assertTrue(list.get(0).pass);
	}

}
